package com.graph;

import java.util.HashMap;
import java.util.List;

public class Vertex {
	
	private int id;
	
	private String label;
	
	private HashMap<String, String> attrs;
	
	public Vertex(int id, String label, List<String> attrNames) {
		this.id = id;
		this.label = label;
		attrs = new HashMap<String, String>();
		for (String attrName : attrNames) {
			attrs.put(attrName, "");
		}
	}
	
	public int getId() {
		return id;
	}
	
	public String getLabel() {
		return label;
	}
	
	public void setAttr(String attrName, String attrValue) {
		attrs.replace(attrName, attrValue);
	}
	
	public String getAttr(String attrName) {
		return attrs.get(attrName);
	}

	@Override
	public String toString() {
		String out = "<Vertex> " + label + ": {";
		for (String attrName : attrs.keySet()) {
			out += attrName + " = " + attrs.get(attrName) + "; ";
		}
		out += "}\n";
		return out;
	}
	
}
